<?php

namespace common\model;

use think\model\RelationModel;

class CosMediaModel extends RelationModel
{

    protected $connection = 'database.mysql_saas';

    protected $tableName = 'cos_media';
    //自动验证
    protected $_validate = [
        ['param', '', '', self::EXISTS_VALIDATE, 'array']
    ];

    //自动完成
    protected $_auto = [
        ['created_by', 'fill_created_by', self::MODEL_INSERT, 'function'],
        ['created', 'time', self::MODEL_INSERT, 'function'],
        ['param', 'json_encode', self::EXISTS_VALIDATE, 'function'],
    ];

    /**
     * 获取器：配置
     * @param $value
     * @return array|mixed
     */
    public function getParamAttr($value)
    {
        if (!empty($value)) {
            return json_decode($value, true);
        }
        return [];
    }

}
